package com.lyncs.ods.resp;

import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.lyncs.ods.modules.txn.model.SettlementDiscountInfo;
import com.lyncs.ods.modules.txn.model.SettlementInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author alex
 * @date 2022/3/12 14:02
 * @description
 */
@Data
@Accessors(chain = true)
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class SettlementDetailInfoResp {

    @ApiModelProperty(value = "结算单ID")
    private Long settlementId;

    @ApiModelProperty(value = "结算单名称")
    private String settlementName;

    @ApiModelProperty(value = "关联交付单数")
    private Long relatedDeliverCount;

    @ApiModelProperty(value = "总金额")
    private BigDecimal totalAmount;

    @ApiModelProperty(value = "状态")
    private Integer status;

    @ApiModelProperty(value = "货币")
    private String currency;

    @ApiModelProperty(value = "是否置顶。true;false")
    private Boolean top;

    @ApiModelProperty("支付方式")
    private String paymentTerms;

    @ApiModelProperty("信用证编号")
    private String certNo;

    @ApiModelProperty("自定义字段信息")
    private String customFields;

    @ApiModelProperty("附件")
    private String attachment;

    @ApiModelProperty(value = "卖方公司信息")
    private CompanyShortInfoResp sellerCompanyInfo;

    @ApiModelProperty(value = "买方公司信息")
    private CompanyShortInfoResp buyerCompanyInfo;

    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "结算截止时间")
    private LocalDate deadline;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "优惠信息")
    private SettlementDiscountInfo discountInfo;

    @ApiModelProperty(value = "创建者用户名称")
    private String creatorName;

    @ApiModelProperty(value = "更新时间")
    private LocalDateTime updateTime;

    @ApiModelProperty(value = "结算日期")
    private LocalDate startDate;

    @ApiModelProperty("上次支付时间")
    private LocalDateTime lastPaymentTime;

    @ApiModelProperty(value = "创建者用户所属公司ID")
    private Long creatorCompanyId;

    @ApiModelProperty(value = "账款信息")
    private List<SettlementBillResp> settlementBillInfos;


    public SettlementDetailInfoResp(SettlementInfo settlementInfo) {
        this.setSettlementId(settlementInfo.getId())
                .setSettlementName(settlementInfo.getSettlementName())
                .setTotalAmount(settlementInfo.getTotalAmount())
                .setStatus(settlementInfo.getStatus())
                .setCreateTime(settlementInfo.getCreateTime())
                .setDeadline(settlementInfo.getDeadline().toLocalDate())
                .setRemark(settlementInfo.getRemark())
                .setUpdateTime(settlementInfo.getUpdateTime())
                .setCurrency(settlementInfo.getCurrency())
                .setCurrency(settlementInfo.getCurrency())
                .setStartDate(settlementInfo.getStartDate())
                .setLastPaymentTime(settlementInfo.getLastPaymentTime())
                .setCreatorCompanyId(settlementInfo.getCreatorCompanyId())
                .setPaymentTerms(settlementInfo.getPaymentTerms())
                .setCertNo(settlementInfo.getCertNo())
                .setAttachment(settlementInfo.getAttachment())
                .setCustomFields(settlementInfo.getCustomFields());
    }
}
